package xyz.canran.tool.frame;

import xyz.canran.tool.panel.ProjectConfigurationPanel;

import javax.swing.*;
import java.awt.*;

public class MainFrame extends JFrame {

    private final int defaultWight = 600;
    private final int defaultHeight = 850;

    public MainFrame() {

        JPanel contentPanel = new ProjectConfigurationPanel();

        this.setContentPane(contentPanel);

        // 设置主面板标题
        this.setTitle("Spring Boot项目生成器");

        // 设置面板宽高
        this.setSize(defaultWight, defaultHeight);

        // 设置点击关闭按钮后退出
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        // 将外边框的最大化和最小化删除掉
        this.setUndecorated(true);
        this.getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG);

        Toolkit toolkit = Toolkit.getDefaultToolkit();
        int x = (int)(toolkit.getScreenSize().getWidth() - this.getWidth())/2;
        int y = (int)(toolkit.getScreenSize().getHeight() - this.getHeight())/2;
        this.setLocation(x, y);

        // 设置是否可见
        this.setVisible(true);

    }

}
